clear all 
set more off

cd "/Users/yasenov/Dropbox/ June 2016/Writeup/Economic Inquiry/EI R and R 2"
use "/Users/yasenov/Dropbox/data_dta/master.dta"
drop if substr(subject, 1, 2) == "it" | substr(subject, 1, 2) == "cs" 
				
tostring id grade year, replace
gen course = grade + " " + subject + " " + cohort
gen class = year + " " + course
gen studentxclass = id + " " + class
gen gradebook = year + grade + cohort
destring id grade year, replace

*******Summary statistics
preserve
collapse (mean) male bulg, by(id)
sum male bulg
restore

preserve
collapse (mean) teacher_male, by(class)
sum teacher_male
restore

preserve
gen lester = 1
collapse (mean) lester, by(id class)
collapse (sum) lester, by(class)
sum lester
restore

tab stem
tab teacher_male
tab late_start

ttest marks, by(male)
ttest marks if teacher_male==1, by(male)
ttest marks if stem==1, by(male)
ttest marks if late_start==1, by(male)
